home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / memory / veum.zip / VCMGR.LC < prev    next >
Text File  |  1987-01-26  |  4KB  |  144 lines

  1. /*
  2.  
  3.     NOTICE:
  4.  
  5.     This code released into public domain with VEMM.EXE, 
  6.     executable version of this and other subroutines.  
  7.  
  8.     For evaluation and documentation purposes only.
  9.  
  10. */
  11.  
  12. #include        "vemm.h"
  13. #include        "regs.h"
  14.  
  15. /*
  16.  
  17.  
  18.     VCMGR                Copyright (C) 1987, Marty Ross
  19.  
  20.  
  21.     This is the VEMM resident manager, using interrupt 0x67
  22.     He intercepts and satisfies a subset of LIM/EMS requests.
  23.     
  24.  
  25.     Functions supported:    (function name passed in ah)
  26.  
  27.     bias = 0x3F        (this value added to cmd name)
  28.  
  29.     name =             (following functions supported)
  30.                 (in all cases, AH is return status: CHECK IT!)
  31.  
  32.         0 -    Internal diagnostic.  Prints current array(s).
  33.  
  34.             1 -     Get Status.  Returns status code in AL.
  35.             2 -    Get Page Frame Address.  Returns PFBA in BX.
  36.             3 -    Get Unallocated Page Count.  Returns DX=total, BX=free
  37.         4 -    Allocate Pages.  Input BX, output DX.
  38.         5 -    Map Handle Page. Input BX, AL, DX.
  39.         6 -    Deallocate Pages.  Input is DX.
  40.         7 -    Get EMM Version.  Output in AX
  41.         
  42.            12 -    Get EMM Handle Count.  Output BX.
  43.            13 -    Get EMM Handle Pages.  Input DX, output BX.
  44.            14 -    Get ALL EMM Handle Pages.  Input ES:DI, output BX.
  45.  
  46.  
  47.     NOTE:    In this version, the memory handle '0' is the 'system pool'
  48.         where all the free pages are stored.  Therefore, the user
  49.         will NEVER be handed a memory handle of zero.  This is 
  50.         NOT the case in an AST RAMPAGE(tm) board: it WILL return
  51.         the first memoryhandle as zero (so don't count on this 
  52.         "feature"-- always check the function return code in AH).
  53.         Later, we will mask out our system handle from the user.
  54.  
  55. */
  56.  
  57. #define            CMD_BIAS    0x3F 
  58. #define            CMD_NAME(f)    (CMD_BIAS+f)
  59.  
  60. extern union REGS vr ; 
  61. extern struct SREGS vsr ; 
  62.  
  63. extern struct vopts vo ;
  64. extern struct vstat vs ; 
  65.  
  66. vcmgr()
  67. {
  68.  
  69. if (vo.debug && !vo.quiet) {
  70.    printf("vcmgr(ax=%04x, bx=%04x, dx=%04x):\n", vr.x.ax, vr.x.bx, vr.x.dx);
  71.    }
  72.  
  73. switch(vr.h.ah) {        /* function code is in ah, select on it */
  74.  
  75.     case CMD_NAME(0):        /* Print internal map */
  76.                 if (vr.h.al==0) vpgmap() ;
  77.                 else if (vr.h.al==1) prt_file() ;
  78.                 else if (vr.h.al==2) prt_errs() ;
  79.                 else if (vr.h.al==3) vpwmap() ;
  80.                 else if (vr.h.al==0xff) vrst() ;
  81.                 vr.h.ah = (char) 0 ; 
  82.                 break;
  83.  
  84.     case CMD_NAME(1):                /* Get Status */
  85.                 vr.h.ah = vs.stat ; 
  86.                 vs.stat = (char) 0 ;    /* Reset also */
  87.                 break;
  88.  
  89.     case CMD_NAME(2):                       /* Get PFBA */
  90.                 vr.x.bx = vs.pfba ; 
  91.                 vr.h.ah = (char) 0 ; 
  92.                 break;
  93.  
  94.     case CMD_NAME(3):            /* Get Unallocate Page Count */
  95.                 vr.x.dx = vs.pages ; 
  96.                 vr.x.bx = vs.vmpgtbl[0][0] ;
  97.                 vr.h.ah = (char) 0 ;
  98.                 break;
  99.  
  100.     case CMD_NAME(4):            /* Allocate Pages */
  101.                 vr.h.ah = (char) vcaloc(vr.x.bx, &vr.x.dx) ;
  102.                 break;
  103.  
  104.     case CMD_NAME(5):            /* Map Handle Pages */
  105.                 vr.h.ah = (char) 
  106.                     vcmap( vr.x.bx, vr.h.al, vr.x.dx ) ;
  107.                 break;
  108.  
  109.     case CMD_NAME(6):            /* Deallocate Pages */
  110.                 vr.h.ah = (char) vcdaloc(vr.x.dx) ; 
  111.                 break;
  112.  
  113.     case CMD_NAME(7):            /* Get EMM Version */
  114.                 vr.h.al = vs.ver ; 
  115.                 vr.h.ah = (char) 0 ;
  116.                 break;
  117.  
  118.     case CMD_NAME(12):            /* Get EMM Handle Count */
  119.                 vr.h.ah = (char) 
  120.                     gaehp(0, vsr.es, vr.x.di, &vr.x.bx) ;
  121.                 break;
  122.  
  123.  
  124.     case CMD_NAME(13):            /* Get EMM Handle Pages */
  125.                 vr.h.ah = (char) gehp(vr.x.dx,&vr.x.bx) ;
  126.                 break;
  127.  
  128.  
  129.     case CMD_NAME(14):            /* Get ALL EMM Handle Pages */
  130.                 vr.h.ah = (char) 
  131.                     gaehp(1, vsr.es, vr.x.di, &vr.x.bx) ;
  132.                 break;
  133.  
  134.     default:                /* Unknown Command */
  135.                 if (vo.debug) {
  136.                    printf("VEMM: Invalid cmd: %02x.\n",
  137.                         vr.h.ah) ;
  138.                    }
  139.                 vr.h.ah = (char) 0x84 ;
  140.                 break; 
  141.     }
  142.  
  143. }
  144.